package pl.vhcreator.domain;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.net.URL;

/**
 *
 * @author aswierc
 */
public class Config {

    private Properties properties; 
    
    private String vhconfig;
    
    public Config() throws IOException
    {
        vhconfig = System.getProperty("user.home") + "/.vhconfig.properties";
        
        File cfgFile = new File(vhconfig);
        cfgFile.createNewFile();
        FileReader reader = new FileReader(cfgFile);
        properties = new Properties();
        properties.load(reader);
    }
    
    public String getValue(String key)
    {
        return properties.getProperty(key);
    }
    
    public void setValue(String key, String value) throws FileNotFoundException, IOException
    {
        properties.setProperty(key, value); 
        properties.store(new FileOutputStream(vhconfig), null);
    }
}
